package com.yuanchu.order.client;

import com.yuanchu.common.utils.R;
import com.yuanchu.order.entity.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @version: 1.0
 * @Author: adan
 * @description: 用户服务
 * @date: 2024-01-24 11:43
 */
@FeignClient(value = "yuanchu-store", fallbackFactory = FeignStoreServiceClientFallbackFactory.class)
public interface FeignStoreClient {

    /**
     * 查询配送模板
     * @param deliveryId
     * @return
     */
    @GetMapping("/store/delivery/{deliveryId}")
    YoshopDeliveryRuleEntity queryDeliveryBigDecimalById(@PathVariable("deliveryId") Integer deliveryId);
    // @PostMapping("/store/delivery/express/price")
    // String queryExpression(@RequestBody List<Integer> deliveryId);
    /**
     * 查询积分配置
     * @return
     */
    @GetMapping("/store/setting/point")
    String queryPointData();
    
    /**
     * 查询用户新增量
     * @return
     */
    @GetMapping("/store/shop/user/count/day")
    Map<String, String> queryNewUserByday();

    /**
     * 查询用户ids
     * @return
     */
    @GetMapping("/store/shop/user/count/ids")
    List<Integer> queryUserIds();

    /**
     * 查询用户信息
     * @param userId
     * @return
     */
    @GetMapping("/store/shop/user/{userId}")
    YoshopUserEntity queryUserByUserId(@PathVariable("userId") Integer userId);

    /**
     * 查询用户地址
     * @param userId 用户id
     * @return
     */
    @GetMapping("/store/shop/address/default")
    YoshopUserAddressEntity queryUserDefaultAddress(@RequestParam("userId") Integer userId, @RequestParam("addressId") Integer addressId);


    /**
     * 查询会员等级
     */
    @GetMapping("store/user/grade/{gradeId}")
    YoshopUserGradeEntity queryUserGrade(@PathVariable("gradeId") Integer gradeId);

    /**
     * 更新用户余额
     * @return
     */
    @PostMapping("store/shop/user/decr/balance")
    R decrUserBalance(@RequestParam("userId") Integer userId, @RequestParam("payMoney") String payMoney,
                             @RequestParam("points") Integer points, @RequestParam("storeId") Integer storeId);


    /**
     * 删除购物车商品
     * @param userId 用户id
     * @param cartIds 购物车id
     * @param storeId 店铺id
     * @return
     */
    @PostMapping("store/cart/del")
    R delCartGoods(@RequestParam("userId") Integer userId, @RequestParam("cartIds") String cartIds, @RequestParam("storeId") Integer storeId);

    @PostMapping("store/balance/log/insert")
    R insertUserBalanceLog(@RequestBody YoshopUserBalanceLogEntity balanceLog);

    @PostMapping("store/points/decr")
    R decrUserPoints(@RequestBody YoshopUserPointsLogEntity user);


    @PostMapping("store/points/bonus")
    R bonusUserPoints(@RequestParam("userId") Integer userId, @RequestParam("orderNo") String orderNo,
                      @RequestParam("pointsBonus") Integer pointsBonus, @RequestParam("storeId") Integer storeId);

    @GetMapping("/store/express/{expressId}")
    YoshopExpressEntity queryExpressById(@PathVariable("expressId") Integer expressId);

    /**
     * 查询商家地址
     * @param addressId
     * @return
     */
    @GetMapping("/store/address/info")
    public YoshopStoreAddressEntity queryStoreAddress(@RequestParam("addressId") Integer addressId);
}
